package com.JSXW.demo;

//public class MethodDemo {
//    public static void main(String[] args) {
//       int d = playGame(10,25);
//        System.out.println(d);
//    }
//    public static int playGame( int a, int b) {
//        int c = a + b;
//        return c;
//    }
//    // 重载方法
//    public  static  String playGame(int a, int b, int c){
//        int d = a + c;
//        return "字符串d";
//    }
//}
public class MethodDemo {
    public static void main(String[] args) {
        int[] arr = {11,22,33,44,55,66,77,88,99};
//        eachHandel(arr);
//         maxHandel(arr);
        int[] copyData = copyOfRange(arr, 3, 6);
    }
//    遍历数组
    public static void eachHandel (int[] arr){
        for (int j : arr) {
            System.out.print(j + " ");
        }
    }
//    获取最大值
    public static  int maxHandel (int[] arr){
        int max = arr[0];
        for (int j : arr) {
            if (j > max) {
                max = j;
            }
        }
        return max;
    }
//     拷贝
    public static int[] copyOfRange(int[] arr, int from, int to){
        int[] newArr = new int[to - from];
        int index = 0; // 伪造索引的思想
        for (int i = from; i < to; i++) {
            newArr[index] = arr[i];
            index++;
        }
        return  newArr;
    }
}